package com.exam;

import hospital.example.Person;

import java.time.*;
import java.time.format.DateTimeFormatter;
import java.util.ArrayList;
import java.util.List;
import java.util.Scanner;

public class Doctor {
    private String begin = "2022-02-03";

    public static void main(String[] args) {
        String begin = "2022-02-03";
        DateTimeFormatter pattern = DateTimeFormatter.ofPattern("yyyy-MM-dd");
        LocalDate date = LocalDate.parse(begin, pattern);
        Scanner sc = new Scanner(System.in);
        System.out.println("请输入格式为yyyy-MM的时间");
        String time = sc.nextLine();
        LocalDate end = LocalDate.parse(time + "-01", pattern);
        Period duration = Period.between(date, end);
        System.out.println(duration.getYears());
        LocalDate end1 = end.plusMonths(1).minusDays(1);
        List<LocalDate> list = new ArrayList<>();
        while(date.isBefore(end)){
            list.add(date);
            date = date.plusDays(3);
        }
        System.out.println("历史休息日: " + list);
        List<LocalDate> list2 = new ArrayList<>();
        while(date.isBefore(end1)){
            list2.add(date);
            date = date.plusDays(3);
        }
        System.out.println("现在休息日: " + list2);
        List<LocalDate> list3 = new ArrayList<>();
        for(LocalDate i : list2){
            if(i.getDayOfWeek() == DayOfWeek.SATURDAY || i.getDayOfWeek() == DayOfWeek.SUNDAY){
                list3.add(i);
            }
        }
        list2.stream().filter(i -> i.getDayOfWeek() == DayOfWeek.SUNDAY || i.getDayOfWeek() == DayOfWeek.SATURDAY).
                forEach(i -> System.out.println(i.getDayOfWeek() == DayOfWeek.SATURDAY?"星期六" + i : "星期日" + i));

        String gaokao = "2026-06-07 09:00";
        pattern = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss");
        LocalDateTime gaokaoTime = LocalDateTime.parse(gaokao + ":00", pattern);
        LocalDateTime now = LocalDateTime.now();
        LocalDate gaokaoshijian = gaokaoTime.toLocalDate();
        LocalDate xianzia = now.toLocalDate();
        Duration dura = Duration.between(now, gaokaoTime);
        Period per = Period.between(xianzia, gaokaoshijian);
        System.out.println("距离2026年高考还有：" + per.getYears() + "年" + per.getMonths() + "月" + per.getDays() + "天" + dura.toHours());

    }
}
